package com.fawvwebanma.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fawvwebanma.entity.User;
import com.fawvwebanma.mapper.UserMapper;

import lombok.extern.slf4j.Slf4j;

/**
 * @author jieye.ren
 * @date 2021/3/15
 */
@Component
@Slf4j
public class UserDao {
    @Autowired
    UserMapper userMapper;

    public void saveUser(User user) {
        userMapper.insert(user);
    }

    public List<User> getAllUsers() {
        return userMapper.selectList(null);
    }

    public void updateUserById(User user) {
        userMapper.updateById(user);
    }

    public void deleteUserById(User user) {
        user.setStatus(0);
        userMapper.updateById(user);
    }
}
